package com.tydic.trans.controller;

import com.tydic.trans.beans.Person;
import com.tydic.trans.service.DemoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Api("SpringBoot-Transaction")
public class MyController {

    @Autowired
    DemoService demoService;

    @PostMapping("/rollback")
    @ApiOperation("回滚")
    public Person rollback(Person person) {
        return demoService.savePersonWithRollBack(person);
    }

    @PostMapping("/norollback")
    @ApiOperation("不回滚")
    public Person noRollback(Person person) {
        return demoService.savePersonWithoutRollBack(person);
    }
}